import { ref, reactive, provide, resolveComponent } from 'vue';
import { useDesign } from '/@/hooks/web/useDesign';
import { randomString } from '/@/utils/common/compUtils';
export function useData(props) {
    const { prefixCls } = useDesign('j-vxe-table');
    provide('prefixCls', prefixCls);
    return {
        prefixCls: prefixCls,
        caseId: `j-vxe-${randomString(8)}`,
        vxeDataSource: ref([]),
        scroll: reactive({ top: 0, left: 0 }),
        scrolling: ref(false),
        defaultVxeProps: reactive({
            rowId: props.rowKey,
            // 高亮hover的行
            highlightHoverRow: true,
            // 溢出隐藏并显示tooltip
            showOverflow: true,
            // 表头溢出隐藏并显示tooltip
            showHeaderOverflow: true,
            showFooterOverflow: true,
            // 可编辑配置
            editConfig: {
                trigger: 'click',
                mode: 'cell',
                activeMethod: () => !props.disabled,
            },
            expandConfig: {
                iconClose: 'ant-table-row-expand-icon ant-table-row-expand-icon-collapsed',
                iconOpen: 'ant-table-row-expand-icon ant-table-row-expand-icon-expanded',
            },
            // 虚拟滚动配置，y轴大于xx条数据时启用虚拟滚动
            scrollY: {
                gt: 30,
            },
            scrollX: {
                gt: 20,
                // 暂时关闭左右虚拟滚动
                enabled: false,
            },
            radioConfig: { highlight: true },
            checkboxConfig: { highlight: true },
            mouseConfig: { selected: false },
            keyboardConfig: {
                // 删除键功能
                isDel: false,
                // Esc键关闭编辑功能
                isEsc: true,
                // Tab 键功能
                isTab: true,
                // 任意键进入编辑（功能键除外）
                isEdit: true,
                // 方向键功能
                isArrow: true,
                // 回车键功能
                isEnter: true,
                // 如果功能被支持，用于 column.type=checkbox|radio，开启空格键切换复选框或单选框状态功能
                isChecked: true,
            },
        }),
        selectedRows: ref([]),
        selectedRowIds: ref([]),
        disabledRowIds: [],
        statistics: reactive({
            has: false,
            sum: [],
            average: [],
        }),
        authsMap: ref(null),
        innerEditRules: {},
        innerLinkageConfig: new Map(),
        reloadEffectRowKeysMap: reactive({}),
    };
}
export function useRefs() {
    return {
        gridRef: ref(),
        subPopoverRef: ref(),
        detailsModalRef: ref(),
    };
}
export function useResolveComponent(...t) {
    // @ts-ignore
    return resolveComponent(...t);
}
